package org.example.road.learn01;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class ThreadTest {
    public static void main(String[] args) {
        // jvm会退出
        testDaemon(true);
        // jvm不会推出
        testDaemon(false);
        log.info("main线程执行完毕");
    }

    public static void testDaemon(boolean isDaemon) {
        Thread thread = new Thread(()->{
            try {
                Thread.sleep(Integer.MAX_VALUE);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        thread.setDaemon(isDaemon);
        thread.start();
    }
}
